package com.example.cofeed.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.example.cofeed.R;
import com.example.cofeed.api.ApiService;
import com.example.cofeed.base.BaseActivity;
import com.example.cofeed.callback.DialogCallback;
import com.example.cofeed.callback.LzyResponse;
import com.example.cofeed.constant.IntentKeyConstant;
import com.lzy.okgo.model.Response;
import com.umeng.analytics.MobclickAgent;

import butterknife.BindView;
import butterknife.OnClick;

public class RegisterStepPhoneActivity extends BaseActivity {

    @BindView(R.id.et_phone)
    EditText mEtPhone;
    @BindView(R.id.tv_next)
    TextView mTvNext;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_register_step_phone;
    }

    @Override
    protected void init(Bundle savedInstanceState, View container) {
        setMainTitle("用户注册");

    }

    @OnClick(R.id.tv_next)
    public void onViewClicked() {
        String phone = mEtPhone.getText().toString().trim();
        if (TextUtils.isEmpty(phone)){
            showToast("请输入手机号码");
            return;
        }

        ApiService.register_first(this, phone, new DialogCallback<LzyResponse<Object>>() {
            @Override
            public void onSuccess(Response<LzyResponse<Object>> response) {
                Intent intent = new Intent(mContext, RegisterActivity.class);
                intent.putExtra(IntentKeyConstant.PHONE, phone);
                startActivity(intent);
                finish();

            }
        });

    }

    @Override
    public void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
    }

    @Override
    public void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);
    }

}
